<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <!--如果是IE 就以标准渲染-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />

    <!-- 视窗——————响应式布局 -->
    <meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />

    <!--当前页面的三要素-->
    <title>运维系统</title>
    <meta name="description" content="聚能优电" />
    <meta http-equiv="keywords" content="聚能优电" />
    <script type="text/javascript" src="./js/verify.js"></script>
    <script type="text/javascript" src="./js/common/commonfuntion.js"></script>
    <!-- css -->
    <link rel="stylesheet" type="text/css" href="./css/common/common.css" />
    <link rel="stylesheet" type="text/css" href="./css/alarm.css" />
    <style>
       
        input.form-control::-webkit-input-placeholder { color:#555; }
        input.form-control::-moz-placeholder { color:#555; } /* Mozilla Firefox 19+ */
        input.form-control:-moz-placeholder { color:#555; } /* Mozilla Firefox 4 to 18 */
        input.form-control:-ms-input-placeholder { color:#555; } /* Internet Explorer 10-11 */
        
    </style>

    <!-- <link rel="stylesheet" type="text/css" href="./css/bootstrap-datetimepicker.css" />
    <link rel="stylesheet" type="text/css" href="./css/font-awesome.min.css" />
    <link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css" /> -->


    <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
    
</head>

<body>
    <div id="container" class="alarm">
        <div class="alarm_01">
            <!--主屏内容-->
            <div class="alarm_screen">
                <div class="m_title" style="height:auto;">
                    <a href="JavaScript:history.go(-1);" class="back">
                        <img src="./images/back.svg" alt="" width="100%">
                    </a>
                    <span class="tit">巡检日志</span>
                </div>
                <div class="m_content">

                    <div class="sb_tit" style="border-bottom:1px dotted #1B3150;height:50px;">
                        <p id="showname" style="float:left;line-height:50px;margin:0;font-size:0.32rem;font-family: SourceHanSansCN-Regular;color: #CDDDF3;letter-spacing: 0;"></p>
                        <input readonly class="form-control" type="text" id="choseMonth" placeholder="月份搜索" style="float:right;width:30%;margin-top:8px;border:1px solid rgba(1,103,255,0.3);border-radius:20px;background:transparent;color:#0167FF;">
                    </div>

                    <div class="gjdata">
                        <div class="data_wrap" id="listdata">
                            <!-- <a href="./order/orderdetail_gj.html" class="datalista">
                                <span class="dataleft">01021</span>
                                <span class="dataright">
                                    <span class="dataleft">工单巡检</span>
                                    <span class="readyaccept">待填报</span>
                                    <span class="dataicon">
                                        <img src="./images/arrowsr.svg" alt="" />
                                    </span>
                                </span>
                            </a>
                            <a href="order/orderdetail_fj.html" class="datalista">
                                <span class="dataleft">01022</span>
                                <span class="dataright">
                                    <span class="dataleft">运维工单</span>
                                    <span class="alreadydone">已完成</span>
                                    <span class="dataicon">
                                        <img src="./images/arrowsr.svg" alt="" />
                                    </span>
                                </span>
                            </a>
                            <a href="" class="datalista">
                                <span class="dataleft">01023</span>
                                <span class="dataright">
                                    <span class="dataleft">系统运维</span>
                                    <span class="bedoing">进行中</span>
                                    <span class="dataicon">
                                        <img src="./images/arrowsr.svg" alt="" />
                                    </span>
                                </span>
                            </a> -->

                        </div>

                    </div>

                </div>

            </div>
        </div>
    </div>


    <script>
        (function (win, doc) {
            var docEl = doc.documentElement || document.body; //获取HTML标签

            var container = doc.getElementById("container"); //container元素
            //判断是移动端设备还是PC,移动 就采用'orientationchange',横竖屏事件，PC端就采用onresize，窗口改变时间
            var resize =
                "onorientationchange" in win ? "orientationchange" : "resize";

            function rem() {
                docEl.style.fontSize = 100 * (container.clientWidth / 750) + "px";
            }

            //监听'DOMContent事件:DOM加载完成执行,如果DOMContent事件，那么执行rem函数
            doc.addEventListener("DOMContentLoaded", rem, false);

            //win下监听resize事件,如果resize事件，那么执行rem函数
            win.addEventListener(resize, rem, false);
        })(window, document);
    </script>
    <!-- js -->
    <script type="text/javascript" src="./js/jquery-3.4.1.js"></script>
    <script type="text/javascript" src="./js/bootstrap.min.js"></script>
    <script type="text/javascript" src="./layer/layer.js"></script>
    <script type="text/javascript" src="./js/rolldate.js"></script>


    <script>
        $(document).ready(function () {

            var projectid = GetQueryString('projectid');
            var projectNameCN = GetQueryString('projectname');
            $("#showname").html(projectNameCN);

            new Rolldate({
				el: '#choseMonth',
				format: 'YYYY-MM',
				beginYear: 2000,
				endYear: 2020,
				confirm: function(date) {
                    let choseyear = Number( date.substring(0,4) );
                    let chosemonth = Number( date.substring(5,7) );
					console.log('确定按钮触发');

                    $.ajax({
                        type: "GET",
                        dataType: "json",
                        url: "http://112.74.169.99:21021/api/services/app/DevOpsService/GetInspectionOrderListByProjectIDAndTime?projectid=" + projectid + "&year=" + choseyear + "&month=" + chosemonth,
                        beforeSend: function (xhr) {
                            xhr.setRequestHeader("Accept",
                                "application/json, text/javascript, */*; q=0.01"
                            );
                            xhr.setRequestHeader("Authorization", accessToken);
                            xhr.setRequestHeader('.AspNetCore.Culture',
                                'zh-Hans');
                        },
                        success: function (res) {

                            // console.log(res);
                            // return;
                            $("#listdata").html(` `);
                            $("#listdata").html(eachdata(res.result));
                        
                        },
                        error: function (err) {
                            console.log("请求失败");
                        }
                    });

				}
			})
           

            updateData(); // 首次加载立即请求数据
            // setInterval(updateData, 1000); // 首次加载之后，每1s重新请求一次数据
            function updateData() { // 请求数据
                $.ajax({
                    type: "GET",
                    dataType: "json",
                    url: "http://112.74.169.99:21021/api/services/app/DevOpsService/GetInspectionOrderListByProjectID?projectid" + projectid,
                    beforeSend: function (xhr) {
                        xhr.setRequestHeader("Accept",
                            "application/json, text/javascript, */*; q=0.01"
                        );
                        xhr.setRequestHeader("Authorization", accessToken);
                        xhr.setRequestHeader('.AspNetCore.Culture',
                            'zh-Hans');
                    },
                    success: function (res) {

                        // console.log(res);
                        // return;
                        $("#listdata").html(` `);
                        $("#listdata").html(eachdata(res.result));
                    
                    },
                    error: function (err) {
                        console.log("请求失败");
                    }
                });

            }


            // 遍历数据
            function eachdata(obj) {
                var str = '';
                if (obj.constructor == Array) {
                    for (var i = 0, len = obj.length; i < len; i++) {
                        var url = '';
                        str += `<a href="` +
                            `/order_project.html?projectID=` + obj[i].projectID + `&projectName=` + obj[i].projectName + `&state=` + obj[i].state + `" class="datalista">`;
                        str += `<span class="dataleft">` + obj[i].time + `</span>`;
                        str += `<span class="dataright">`;
                        if (obj[i].state == 1) {
                            str += `<span class="alreadydone">已完成</span>`;
                        } else if (obj[i].state == 0) {
                            str += `<span class="readyaccept">待填报</span>`;
                        }
                        str += `<span class="dataicon">`;
                        str += `<img src="./images/arrowsr.svg" alt="" />`;
                        str += `</span>`;
                        str += `</span>`;
                        str += `</a>`;
                    }
                    return str;
                }
            }
        });
    </script>

</body>

</html>